package com.gzsxy.esjy.service.core.sign.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 文书类型
 * @author zhangxiaolong
 * @date 2022/7/13 11:36
 */
@Getter
public enum DocumentEnum {

	/**
	 *
	 */
    INTERROGATION(1, 4, "提讯提解证"),
    ARREST_WARRANT(4, 1, "逮捕证"),
    CHANGE_CUSTODY(5, 2, "变更羁押通知书"),
    APPRAISAL_OPINION(6, 3, "鉴定意见通知书"),
    ARREST_TRANSFER(9, -1, "逮捕-移送审查起诉告知书");

    /**
     * 文书类型
     */
    private Integer type;
    /**
     * 闭环类型
     */
    private Integer closedCycleType;
    /**
     * 文书名称
     */
    private String name;

    private DocumentEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    private DocumentEnum(Integer type, Integer closedCycleType, String name) {
        this.type = type;
        this.closedCycleType = closedCycleType;
        this.name = name;
    }


    /**
     * 得到所有文书类型
     *
     * @return
     */
    public static List<Integer> getAllDocumentList() {
        List<Integer> documentTypeList = new ArrayList<>();
        for (DocumentEnum e : values()) {
            documentTypeList.add(e.getType());
        }
        return documentTypeList;
    }

    /**
     * 通过文件类型获取枚举
     *
     * @param type
     * @return
     */
    public static DocumentEnum getByType(int type) {
        for (DocumentEnum s : values()) {
            if (s.getType() == type) {
                return s;
            }
        }
        return null;
    }

    /**
     * 通过闭环type获取系统type
     *
     * @param closedCycleType
     * @return
     */
    public static Integer getTypeByClosedCycleType(Integer closedCycleType) {
        for (DocumentEnum s : values()) {
            if (s.getClosedCycleType() == closedCycleType) {
                return s.getType();
            }
        }
        return null;
    }
}
